package com.maixun.lib_business_college.home

import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.android.material.tabs.TabLayoutMediator
import com.lmoumou.lib_comment.CommentPagerAdapter
import com.maixun.lib_business_college.R
import com.maixun.lib_business_college.qa.new_qa.NewQAFragment
import com.maixun.lib_business_college.qa.wait_qa.WaitQAFragment
import com.maixun.lib_comment.ARouterConstance
import com.maixun.lib_comment.ui.BaseMVPFragment
import kotlinx.android.synthetic.main.college_fragment_college.*

/**
 * @author：Lmoumou
 * @date：2020/10/14
 */
@Route(path = ARouterConstance.COLLEGE.URL_COLLEGE_MAIN)
class CollegeFragment : BaseMVPFragment<CollegePresenterImpl>(), CollegeContract.View {
    override val mPresenter: CollegePresenterImpl by lazy { CollegePresenterImpl(this) }

    override fun getLayoutId(): Int = R.layout.college_fragment_college

    override fun isLazyLoad(): Boolean = true

    override fun loadData() {

    }

    private val fragmentList by lazy {
        mutableListOf(
            NewQAFragment.newInstance(),
            WaitQAFragment.newInstance()
        )
    }

    private val titleArray by lazy { arrayOf("最新回答", "等待回答") }

    private val pagerAdapter by lazy { CommentPagerAdapter(this, fragmentList) }
    override fun initView(rootView: View, savedInstanceState: Bundle?) {
        mViewPager.adapter = pagerAdapter

        TabLayoutMediator(
            mTabLayout,
            mViewPager,
            TabLayoutMediator.TabConfigurationStrategy { tab, position ->
                tab.text = titleArray[position]
            }).attach()
    }


}